//
//  LSRollingDetailView.m
//  LookScore
//
//  Created by wws on 2018/5/4.
//  Copyright © 2018年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSRollingDetailView.h"
#import "EdgeInsetsLabel.h"
#import "LSRecommendDetailModel.h"
@implementation LSRollingDetailView{
    UILabel * _titleLabel;
    UILabel * _timeLabel;
    UIImageView * _iconImageView;
    UILabel * _nickNameLabel;
    EdgeInsetsLabel * _leftShootingLab;
    EdgeInsetsLabel * _shootingNumbLabel;
    
    UILabel * _shootingLab;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        [self addContentView];
    }
    return self;
}

- (void)addContentView{
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.text = @"罗马主场能否再次上演奇迹？";
    _titleLabel.font = LSFontBoldSize15;
    _titleLabel.numberOfLines = 1;
    _titleLabel.textColor = LSTitleGrayColor1;
    [self addSubview:_titleLabel];
    _titleLabel.sd_layout
    .leftSpaceToView(self, 10)
    .topSpaceToView(self, 10)
    .rightSpaceToView(self, 10)
    .autoHeightRatio(0);
    
    
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.text = @"05-02发布";
    _timeLabel.font = LSFontSize12;
    _timeLabel.numberOfLines = 1;
    _timeLabel.textColor = LSTitleGrayColor2;
    [self addSubview:_timeLabel];
    _timeLabel.sd_layout
    .leftSpaceToView(self, 10)
    .topSpaceToView(_titleLabel, 10)
    .rightSpaceToView(self, 10)
    .autoHeightRatio(0);
    
    UIView * lineView = [[UIView alloc] init];
    lineView.backgroundColor = LSLineGrayColor;
    [self addSubview:lineView];
    lineView.sd_layout
    .leftEqualToView(self)
    .rightEqualToView(self)
    .topSpaceToView(_timeLabel, 10)
    .heightIs(1);
    
    _iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo1"]];
    [self addSubview:_iconImageView];
    _iconImageView.sd_layout
    .leftEqualToView(_timeLabel)
    .topSpaceToView(lineView, 10)
    .widthIs(50)
    .heightIs(49);
    
    
    _nickNameLabel = [[UILabel alloc] init];
    _nickNameLabel.text = @"05-02发布";
    _nickNameLabel.font = LSFontSize12;
    _nickNameLabel.numberOfLines = 1;
    _nickNameLabel.textColor = LSTitleGrayColor2;
    [self addSubview:_nickNameLabel];
    _nickNameLabel.sd_layout
    .leftSpaceToView(_iconImageView, 10)
    .topSpaceToView(lineView, 13)
    .autoHeightRatio(0);
    [_nickNameLabel setSingleLineAutoResizeWithMaxWidth:180];
    
    
    _leftShootingLab = [[EdgeInsetsLabel alloc] init];
    _leftShootingLab.text = @"100%命中率";
    _leftShootingLab.textAlignment = NSTextAlignmentCenter;
    _leftShootingLab.textColor = [UIColor orangeColor];
    _leftShootingLab.font = LSFontSize10;
    _leftShootingLab.layer.borderColor = [UIColor orangeColor].CGColor;
    _leftShootingLab.layer.cornerRadius = 4;
    _leftShootingLab.layer.borderWidth = 0.5;
    
    [self addSubview:_leftShootingLab];
    _leftShootingLab.sd_layout
    .leftEqualToView(_nickNameLabel)
    .topSpaceToView(_nickNameLabel, 3)
    .widthIs(70)
    .autoHeightRatio(0);
//    [_leftShootingLab setSingleLineAutoResizeWithMaxWidth:180];
    _leftShootingLab.contentInset = UIEdgeInsetsMake(2, 2, 2, 2);
    
    
    _shootingNumbLabel = [[EdgeInsetsLabel alloc] init];
    _shootingNumbLabel.text = @"近13中12";
    _shootingNumbLabel.textAlignment = NSTextAlignmentCenter;
    _shootingNumbLabel.textColor = [UIColor orangeColor];
    _shootingNumbLabel.font = LSFontSize10;
    _shootingNumbLabel.layer.borderWidth = 0.5;
    _shootingNumbLabel.layer.borderColor = [UIColor orangeColor].CGColor;
    _shootingNumbLabel.cornerRadius = 4;
    
    [self addSubview:_shootingNumbLabel];
    _shootingNumbLabel.sd_layout
    .leftSpaceToView(_leftShootingLab, 3)
    .centerYEqualToView(_leftShootingLab)
    .widthIs(65)
    .autoHeightRatio(0);
//    [_shootingNumbLabel setSingleLineAutoResizeWithMaxWidth:180];
    _shootingNumbLabel.contentInset = UIEdgeInsetsMake(2, 2, 2, 2);
    
    _shootingLab = [[UILabel alloc] init];
    _shootingLab.font = LSFontSize12;
    _shootingLab.text = @"100%\n命中率";
    _shootingLab.textColor = [UIColor redColor];
    [self addSubview:_shootingLab];
    _shootingLab.sd_layout
    .rightSpaceToView(self, 10)
    .topSpaceToView(lineView, 10)
    .autoHeightRatio(0);
    [_shootingLab setSingleLineAutoResizeWithMaxWidth:180];
}
- (void)setModel:(LSRecommendDetailModel *)model{
    _model = model;
    
    _titleLabel.text = model.Title;
    _timeLabel.text = model.CreateTime;
    _nickNameLabel.text = model.UserDisName;
    [_iconImageView sd_setImageWithURL:[NSURL URLWithString:model.UserHeadUrl] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
//        image = [CommonClass clipImage:image scaleToSize:CGSizeMake(50, 50)];
    }];
    _leftShootingLab.text = [NSString stringWithFormat:@"%@命中率",model.RightRate];
    _shootingNumbLabel.text = [NSString stringWithFormat:@"%@",model.RecentResult];
    _shootingLab.text = [NSString stringWithFormat:@"%@\n命中率",model.RightRate];
}
@end
